(function() {

    var __vegStore = new Object;
    
    function VegData(name, desc, seedPrice, price, numSeason, numStage, numMature, harvestExp, levelLimit, firstMatureTime, otherMatureTime)
    {
        this.name = name;
        this.desc = desc;
        this.seedPrice = seedPrice;
        this.price = price;
        this.numSeason = numSeason;
        this.numStage = numStage;
        this.numMature = numMature;
        this.harvestExp = harvestExp;
        this.levelLimit = levelLimit;
        this.firstMatureTime = firstMatureTime;
        this.otherMatureTime = otherMatureTime;
    }
    
    VegData.prototype.getStageImgData = function(stage)
    {
        assert (stage < this.stageImages.length, "stage " + stage + "must < total stages num = " + this.stageImages.length);
        return this.stageImages[stage];
    }

    VegData.prototype.getFlowerImgData = function()
    {
        return this.flowerImage;
    }
    
    VegData.prototype.getHarvestImgData = function()
    {
        return this.afterHarvestImage;
    }
    
    VegData.prototype.generateVegNum = function()
    {
        return getRandInt(-3, 3) + this.numMature;
    }
    
    VegData.prototype.getMatureTime = function(first)
    {
        if (first)
        {
            return this.firstMatureTime;
        }
        else
        {
            return this.otherMatureTime;
        }
    }

    function fillDefaultVegImageData(veg)
    {
        veg.stageImages = [];
        veg.stageImages.push({img : PLANTS_SEED, offset : new Point(12, -5)});
        veg.stageImages.push({img : PLATNS_STAGE_0, offset : new Point(12, -25)});
        veg.stageImages.push({img : PLATNS_STAGE_1, offset : new Point(2, -40)});
        veg.stageImages.push({img : PLATNS_STAGE_2, offset : new Point(-23, -70)});
        veg.stageImages.push({img : PLATNS_STAGE_3, offset : new Point(-31, -90)});
        veg.stageImages.push({img : PLATNS_STAGE_4, offset : new Point(-37, -100)});
        veg.flowerImage = {img : PLATNS_STAGE_5, offset : new Point(-42, -102)};
        veg.afterHarvestImage = {img : PLATNS_STAGE_6, offset : new Point(-40, -26)};
        veg.seedIcon = null;
    }
    
    function createRandomVeg(idx)
    {
        var veg = new VegData("veg" + idx, 
            "some desc" + idx, 
            getRandInt(30, 500),
            getRandInt(10, 100),
            getRandInt(20,30),
            6,
            getRandInt(1, 5),
            getRandInt(25, 60),
            idx,
            getRandInt(10, 300),
            getRandInt(50, 150)
        );
        fillDefaultVegImageData(veg);
        return veg;
    }
    
    function createFakeVegData()
    {
        return vegStore;
    }

    StaticModels = new Object();
    StaticModels.createFakeData = function()
    {
        var i = 0;
        for (i = 0; i < 20; i++)
        {
            var veg = createRandomVeg(i);
            __vegStore[veg.name] = veg;
        }
    }
    
    StaticModels.getRandomFakeVeg = function()
    {
        return __vegStore[this.getRandomFakeVegName()];
    }
    
    StaticModels.getRandomFakeVegName = function()
    {
        return "veg" + getRandInt(0, 19);
    }
    
    StaticModels.getVegStore = function()
    {
        return __vegStore;
    }
    
    StaticModels.getVegInfo = function(vegName)
    {
        return __vegStore[vegName];
    }
    
})();